import { Spin } from 'antd'
import { CSSProperties, Suspense } from 'react'
const loadingStyle: CSSProperties = {
  display: 'flex',
  justifyContent: 'center',
  alignItems: 'center',
  width: '100%',
  minHeight: 'inherit'
}
const lazyLoad = (Component: React.LazyExoticComponent<() => JSX.Element>) => {
  return (
    <Suspense
      fallback={
        <div style={loadingStyle}>
          <Spin size="large"></Spin>
        </div>
      }
    >
      <Component />
    </Suspense>
  )
}

export default lazyLoad
